<template>
	<newlist :news="news" @itemClick="goDetail"></newlist>
</template>

<script>
	import newlist from '../../components/news-list/news-list.vue'
	export default {
		data() {
			return {
				news: []
			}
		},
		onLoad() {
			this.getNews()
		},
		components:{
			newlist
		},
		methods: {
			// 获取资讯列表
			async getNews(){
				const res = await this.$myRequest({
					url:'/getnewslist'
				})
				this.news = res.data.message
			},
			// 跳转去详情页
			goDetail(id){
				// https://uniapp.dcloud.io/api/router?id=navigateto
				uni.navigateTo({
					url:`/pages/news-detail/news-detail?id=${id}`
				})
				console.log(id)
			}
		}
	}
</script>

<style lang="scss">
	.news{
		.news_item{
			display: flex;
			border-bottom: 1px solid $shop-color;
			padding: 10rpx 20rpx;
			image{
				width: 200rpx;
				height: 150rpx;
			}
			
			.right{
				margin-left: 10rpx;
				
				.title{
					font-size: 30rpx;
				}
				.info{
					margin-top: 15px;
					font-size: 24rpx;
					text:nth-child(2){
						margin-left: 30rpx;
					}
				}
			}
		}
	}
</style>
